package com.ebpm.designer.dir
{
	import com.ebpm.designer.WF;
	import com.ebpm.designer.WP;
	import com.ebpm.designer.line.Line;
	
	import flash.events.MouseEvent;
	
	import mx.containers.Canvas;
	
	//线 中间点拖拽框
	public class LineMiddleDir extends Canvas
	{
		public var line:Line;
		public var imgType:String;
		
		public function LineMiddleDir(line:Line, imgType:String)
		{
			this.line = line;
			this.imgType = imgType;
			this.initStyle();
			this.addEventListener(MouseEvent.MOUSE_OVER, _mouseOver);
			this.addEventListener(MouseEvent.MOUSE_OUT, _mouseOut);
			this.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDown);
			this.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
		}
		
		private function initStyle():void {
			this.width = WF.ITEM_SIZE;
			this.height = WF.ITEM_SIZE;
			this.setStyle("borderColor", WF.ITEM_BORDER_COLOR);
			this.setStyle("backgroundColor", WF.ITEM_BGCOLOR);
			this.setStyle("borderStyle", "solid");
		}
		
		public function _mouseOut(event:MouseEvent):void
		{
			this.cursorManager.removeAllCursors();
		}
		
		public function _mouseDown(event:MouseEvent):void
		{
			WP.isAllowSelectNodeContainers = false;
			this.line.isAlreadyResize = true;
			this.line.isFirstMove = true;
			WP.isMovingMiddleLineDir = true;
			WF.wp.selectLine = this.line;	
		}
		
		public function _mouseUp(event:MouseEvent):void
		{
			this.line.removeDir();
		}
		
		//鼠标样式交给子类实现
		public function _mouseOver(event:MouseEvent):void {
			if(imgType == "leftRightIcon") {
				this.cursorManager.setCursor(WF.Icon_Resize_LeftRight);
			} else if(imgType == "upDownIcon") {
				this.cursorManager.setCursor(WF.Icon_Resize_UpDown);
			}
		}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
	}
}